package com.agilegroup.crm.ui.actions;

import com.actionbarsherlock.app.SherlockDialogFragment;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
import com.agilegroup.crm.R;
import com.agilegroup.crm.ui.fragments.AboutDialogFragment;
import com.agilegroup.crm.ui.fragments.ExitDialogFragment;
import com.agilegroup.crm.utils.SessionManager;
//import com.asset.salesforce.ui.actions.CalendarSync;

/**
 * @author Hisham
 *
 */
public class MenuHandler {

	public static void handleOnItemSelected(MenuItem item,SherlockFragmentActivity activity) {
		switch (item.getItemId()) {
		case R.id.action_about:{
			SherlockDialogFragment dialogFragment = new AboutDialogFragment();
			dialogFragment.show(activity.getSupportFragmentManager(), "aboutDialog");
		}
		break;
		case R.id.action_exit:{
			SherlockDialogFragment dialogFragment = new ExitDialogFragment();
			dialogFragment.show(activity.getSupportFragmentManager(), "exitDialog");
//			Intent exit = new Intent(activity,ExitDialogActivity.class);
//			activity.startActivity(exit);
//			SherlockDialogFragment newFragment = new ExitDialogFragment();
//    	    newFragment.show(activity.getSupportFragmentManager(), "exitDialog");
		}
		break;
		case R.id.action_logout:{
			SessionManager session = new SessionManager(activity.getApplicationContext());
			session.logoutUser();
			activity.finish();
		}
		break;

		default:
			break;
		}
	}
}
